let vm = new Vue({
    el:'.main-container',  //选中整个main
    data:{
        menu:{},//初始化对象     vue建议声明对象同时进行初始化，避免undefinded
    },
    methods:{
        updateMenu:function () {
            axios({
                url:'/guguanjia/manager/menu/updateMenuById',
                method:'put',
                data:this.menu
            }).then(response=>{
                //不成功提示
                if(response.data.success){
                    let index = parent.layer.getFrameIndex(window.name);//根据当前窗体名字获取其索引值
                    //console.log(index);
                    parent.layer.close(index);//根据索引值关闭子窗口
                    parent.layer.msg("更新成功");//根据索引值关闭子窗口
                }else {
                    layer.msg(response.data.msg);
                }
            }).catch(error=>{
                layer.msg(error.message);
            })
        },
        cancelUpdate:function () {
            let index = parent.layer.getFrameIndex(window.name);//根据当前窗体名字获取其索引值
            //console.log(index);
            parent.layer.close(index);//根据索引值关闭子窗口
            parent.layer.msg("取消修改");
        },
        toSelect: function (id) {
            layer.obj = id;
            layer.open({
                type: 2,
                title: '选择',
                maxmin: true,
                // shadeClose: true, //点击遮罩关闭层
                area: ['90%', '70%'],
                content: 'menu/menu-select.html',
                end: () => {
                    if (layer.parentName != undefined && layer.parentName != this.menu.parentName && layer.parentName.length > 0) {
                        this.menu.parentName = layer.parentName;
                        this.menu.parentId = layer.aid;
                        // console.log(this.office)
                    }
                }
            });
        },
        // modules/fontAwesome.html
        toModule: function (id) {
            layer.obj = id;
            layer.open({
                type: 2,
                title: '选择',
                maxmin: true,
                // shadeClose: true, //点击遮罩关闭层
                area: ['90%', '70%'],
                content: 'modules/fontAwesome.html',
                end: () => {
                    if (this.menu.icon != layer.icon && layer.icon != this.menu.icon && layer.icon.length > 0) {
                        this.menu.icon = layer.icon;
                    }
                }
            });
        },
    },
    created:function () {
        this.menu = parent.layer.obj;
        console.log(this.menu);
        //console.log(parent.layer.obj);
    },

});